package com.onlyxiahui.framework.net.session;

import java.util.HashMap;
import java.util.Map;

/**
 *
 * Date 2018-12-30 10:39:53<br>
 * Description
 *
 * @author XiaHui<br>
 * @since 1.0.0
 */
public abstract class AbstractSession implements SocketSession {

    private String key;
    private String tag;
    private final Map<Object, Object> attributeMap = new HashMap<>();
    private boolean auth = false;

    @Override
    public void addAttribute(Object key, Object value) {
        attributeMap.put(key, value);
    }

    @SuppressWarnings("unchecked")
    @Override
    public <T> T getAttribute(Object key) {
        return (T) attributeMap.get(key);
    }

    @Override
    public void setKey(String key) {
        this.key = key;
    }

    @Override
    public String getKey() {
        return key;
    }

    @Override
    public boolean isAuth() {
        return auth;
    }

    @Override
    public void setAuth(boolean auth) {
        this.auth = auth;
    }

    @Override
    public String getTag() {
        return tag;
    }

    @Override
    public void setTag(String tag) {
        this.tag = tag;
    }
}
